﻿using UnityEngine;
using System.Collections;

public class CristalFin : MonoBehaviour {



	
	public GameObject cible;
	public GameObject loadScreen;


	IEnumerator Wait() {
		Debug.Log("Before Waiting 2 seconds");
		yield return new WaitForSeconds(2);
		Debug.Log("After Waiting 2 Seconds");
	}

	void Awake () {
		this.gameObject.SetActive (false);
	}

	void fin()
	{
		cible.GetComponent<Avancement>().fin = true;
		loadScreen.animation.Play ();
		Invoke ("finNiveau", 5);

	}

	void finNiveau()
	{
		Application.LoadLevel ("Niveau2");
	}


	void OnTriggerEnter2D(Collider2D coll){

		if (coll.gameObject.tag != "player"){
			if(coll.gameObject.tag == "Water_Bolt")
			{
				PontController.moving = true;
				Destroy (coll.gameObject);
				this.gameObject.SetActive(false);
				Invoke ("fin",2.4f);


			}
		}

	}

}


